package com.github.prontera.service;

import java.math.BigDecimal;
import java.time.OffsetDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.prontera.domain.ClientWechat;
import com.github.prontera.persistence.CrudMapper;

/**
 * 用户查看微信
 */
@Service
public class ClientWechatService extends CrudServiceImpl<ClientWechat>{

	@Autowired
    public ClientWechatService(CrudMapper<ClientWechat> mapper) {
        super(mapper);
    }

  	@Transactional(propagation = Propagation.REQUIRED)
  	public boolean insert(Long clientId,Long lookClientId,BigDecimal payAmount) {
  		ClientWechat clientWechat=new ClientWechat();
  		clientWechat.setLookClientId(lookClientId);
  		clientWechat.setClientId(clientId);
  		clientWechat.setPayAmount(payAmount);
  		clientWechat.setPayTime(OffsetDateTime.now());
  		return mapper.insert(clientWechat)>0;
	}
  	
}
